package com.wanlong.common.result;

import java.io.Serializable;

/**
 * @author 万龙
 * @name
 * @project_name wanlong
 * @package_name com.wanlong.common
 * @description
 * @date 2019/3/10
 */
public class ResponseResult<T> implements Serializable {

    private static final long serialVersionUID = 1L;

    public static final String SUCCESS = "0000";
    public static final String FAILURE = "-1";

    private String code;//返回编码
    private String msg;//返回说明
    private T data;//返回数据
    private String token;//TOKEN

    public ResponseResult() {}

    public ResponseResult(String code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public static String getSUCCESS() {
        return SUCCESS;
    }

    public static String getFAILURE() {
        return FAILURE;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    private static <T> ResponseResult<T> create(String code, String msg, T data) {
        return new ResponseResult<T>(code,msg,data);
    }

    public static <T> ResponseResult<T> failure(String msg){
        return new ResponseResult<T>(FAILURE,msg,null);
    }

    public static <T> ResponseResult<T> success(T data){
        return create(SUCCESS,"操作成功",data);
    }
    private static<T> ResponseResult<T> failure(){
        return failure("操作失败");
    }


}
